﻿using UnityEngine;
using System.Collections;
using GDGeek;
using System.Collections.Generic;
using Models;

public class CommonHelper 
{

    public static void ClosePlayerMove()
    {
        GameObject player = GameObject.Find("GameMainPlayer");
        if (player != null)
        {
            player.GetComponent<BaseControlMove>().ClosePlayerMove();
        }
        else
        {
            Debug.Log("Player is null");
        }
    }

    public static void SetPlayerTouchZerosss()
    {
        GameObject player = GameObject.Find("GameMainPlayer");
        if (player != null)
        {
           // player.GetComponent<BaseControlMove>().SetNow_transformedDirectionNull();
        }
        else
        {
            Debug.Log("SetNow_transformedDirectionNull error");
        }
    }


    public static void OpenPlayerMove()
    {
        GameObject player = GameObject.Find("GameMainPlayer");
        if (player != null)
        {
            player.GetComponent<BaseControlMove>().OpenPlayerMove();
        }
        else
        {
            Debug.Log("Player is null");
        }
    }

    public static void SetEnemyOutOfScreen(GameObject e)
    {
        e.transform.position = new Vector3(-3, 13, 0);
    }


    public static string GetZhuangBeiAttackFirePrefabName()
    {
        string attack_prefab = "";
        GamePerson person = GameDataManager.Instance.GetGamePerson();


        foreach (KeyValuePair<int, PersonZhuangBeiItem> kv in person.zb_bag.bag)
        {

            if (kv.Value.type == PersonZhuangBeiType.Wuqi && kv.Value.isZhuangBei)
            {
                attack_prefab = kv.Value.fire_name;
            }

        }
        if (attack_prefab == "")
        {
            return attack_prefab;
        }
        else
        {
            return attack_prefab;
        }

    }



    public static int GetZhuangBeiAttack()
    {
        int attack_zhuangbei = 0;
        GamePerson person = GameDataManager.Instance.GetGamePerson();


        foreach (KeyValuePair<int, PersonZhuangBeiItem> kv in person.zb_bag.bag)
        {

            if (kv.Value.type == PersonZhuangBeiType.Wuqi && kv.Value.isZhuangBei)
            {
                attack_zhuangbei = kv.Value.Attack;
            }

        }

        return attack_zhuangbei;

    }

    public static int GetZhuangBeiFangWei()
    {
        int fangwei_zhuangbei = 0;
        GamePerson person = GameDataManager.Instance.GetGamePerson();

        foreach (KeyValuePair<int, PersonZhuangBeiItem> kv in person.zb_bag.bag)
        {

            if (kv.Value.type != PersonZhuangBeiType.Wuqi && kv.Value.isZhuangBei)
            {
                fangwei_zhuangbei += kv.Value.FangYu;
            }

        }

        return fangwei_zhuangbei;
    }




}
